//
//  DengerousCell.m
//  掌上宏力
//
//  Created by admin on 2017/6/7.
//  Copyright © 2017年 admin. All rights reserved.
//

#import "DengerousCell.h"
#import "DengerousFrame.h"
#import "DengerousModel.h"

@interface DengerousCell ()

@property (nonatomic,weak) UILabel *nameL;
@property (nonatomic,weak) UILabel *nameLab;
@property (nonatomic,weak) UILabel *fromL;
@property (nonatomic,weak) UILabel *fromLab;
@property (nonatomic,weak) UILabel *issueL;
@property (nonatomic,weak) UILabel *issueLab;
@property (nonatomic,weak) UILabel *issueContentL;
@property (nonatomic,weak) UILabel *issueContentLab;
@property (nonatomic,weak) UILabel *doctorL;
@property (nonatomic,weak) UILabel *doctorLab;

@property (nonatomic,weak) UIView *view;

@end

@implementation DengerousCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        UIView *view = [[UIView alloc] init];
        view.backgroundColor = [UIColor whiteColor];
        view.layer.cornerRadius = 5;
        [self.contentView addSubview:view];
        self.view = view;
        NSArray *titles = @[@"患者姓名:",@"患者来源:",@"发  布  人:",@"发布内容:",@"处理医生:"];
        UILabel *nameL = [self createLabWithTitle:titles[0] Font:15];
        [view addSubview:nameL];
        self.nameL = nameL;
        UILabel *nameLab = [self createLabWithFont:15];
        [view addSubview:nameLab];
        self.nameLab = nameLab;
        
        UILabel *fromL= [self createLabWithTitle:titles[1] Font:15];
        [view addSubview:fromL];
        self.fromL = fromL;
        UILabel *fromLab = [self createLabWithFont:15];
        [view addSubview:fromLab];
        self.fromLab = fromLab;
        
        UILabel *issueL = [self createLabWithTitle:titles[2] Font:15];
        [view addSubview:issueL];
        self.issueL = issueL;
        UILabel *issueLab = [self createLabWithFont:15];
        [view addSubview:issueLab];
        self.issueLab = issueLab;
        
        UILabel *issueContentL = [self createLabWithTitle:titles[3] Font:15];
        [view addSubview:issueContentL];
        self.issueContentL = issueContentL;
        UILabel *issueContentLab = [self createLabWithFont:15];
        issueContentLab.numberOfLines = 0;
        [view addSubview:issueContentLab];
        self.issueContentLab = issueContentLab;
        
        UILabel *doctorL = [self createLabWithTitle:titles[4] Font:15];
        [view addSubview:doctorL];
        self.doctorL = doctorL;
        UILabel *doctorLab = [self createLabWithFont:15];
        [view addSubview:doctorLab];
        self.doctorLab = doctorLab;
        
    }
    return self;
}

-(UILabel *)createLabWithFont:(CGFloat)font{
    return [self createLabWithTitle:@"" Font:font];
}
-(UILabel *)createLabWithTitle:(NSString *)title Font:(CGFloat)font{
    UILabel *lab = [[UILabel alloc] init];
    lab.font = [UIFont systemFontOfSize:font];
    lab.text = title;
    return lab;
}
-(void)setDengerF:(DengerousFrame *)dengerF{
    _dengerF = dengerF;
    [self settingData];
    [self settingFrame];
}

-(void)settingData{
    DengerousModel *denger = _dengerF.dengerous;
    self.nameLab.text = denger.name;
    self.fromLab.text = denger.from;
    self.issueLab.text = denger.issueMen;
    self.issueContentLab.text = denger.issueContent;
    self.doctorLab.text = denger.doctor;
}

-(void)settingFrame{
    self.nameL.frame = _dengerF.nameF;
    self.nameLab.frame = _dengerF.nameLabF;
    self.fromL.frame = _dengerF.fromF;
    self.fromLab.frame = _dengerF.fromLabF;
    self.issueL.frame = _dengerF.issueF;
    self.issueLab.frame = _dengerF.issueLabF;
    self.issueContentL.frame = _dengerF.issueContentF;
    self.issueContentLab.frame = _dengerF.issueContentLabF;
    self.doctorL.frame = _dengerF.doctorF;
    self.doctorLab.frame = _dengerF.doctorLabF;
    self.view.frame = CGRectMake(10, 0, kScreenW-20, _dengerF.cellHeight);
}

+(instancetype)cellWithTableView:(UITableView *)tableView{
    static NSString *cellId = @"cellId";
    DengerousCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    if (cell == nil) {
        cell = [[DengerousCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellId];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.backgroundColor = [UIColor clearColor];
    return cell;
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
